using System.Numerics;
using collision_and_rigid;
using game_config;

namespace game_stuff
{
    public class EventStatus
    {
        public static readonly EventStatus Zero = new EventStatus();
        private float BeHitDecAdd { get; set; }
        private float BeHitDecMax { get; set; }
        private float BeHitDmgAdd { get; set; }
        private float BeHitDmgMax { get; set; }
        private float TeleportDmgAdd { get; set; }
        public int SwitchDmgStack { get; private set; }
        public float NowDmgAdd { get; private set; }
        public float NowDec { get; private set; }

        public int OverAmmoShieldRegenStack { get; private set; }


        public float MainBeHitRecharge { get; private set; }

        public EventStatus()
        {
            BeHitDecAdd = 0;
            BeHitDecMax = 0;
            BeHitDmgAdd = 0;
            BeHitDmgMax = 0;
            TeleportDmgAdd = 0;
            SwitchDmgStack = 0;
            NowDmgAdd = 0;
            NowDec = 0;
            OverAmmoShieldRegenStack = 0;
            MainBeHitRecharge = 0;
        }

        public void Refresh(float[] vector)
        {
            BeHitDecAdd = vector[0];
            BeHitDecMax = vector[1];
            BeHitDmgAdd = vector[2];
            BeHitDmgMax = vector[3];
            TeleportDmgAdd = vector[4];
            var id = CommonConfig.OtherConfig!.switch_Weapon_Buff;
            var f = CommonConfig.Configs.play_buffs[id].EffectValue;
            SwitchDmgStack = (int)(vector[5] / f);
            var overAmmoShieldRegenBuff = CommonConfig.OtherConfig!.OverAmmoShieldRegenBuff;
            var f2 = CommonConfig.Configs.play_buffs[overAmmoShieldRegenBuff].EffectValue;
            OverAmmoShieldRegenStack = (int)(vector[6] / f2);
            MainBeHitRecharge = vector[7];
        }

        public void Clear()
        {
            NowDec = 0f;
            NowDmgAdd = 0f;
        }

        public void Teleport()
        {
            NowDmgAdd = MathTools.Max(0, TeleportDmgAdd + NowDmgAdd);
        }

        public void BeDamageEffect()
        {
            NowDmgAdd = MathTools.Max(0, MathTools.Min(BeHitDmgMax, BeHitDmgAdd + NowDmgAdd));
            NowDec = MathTools.Max(0, MathTools.Min(BeHitDecMax, BeHitDecAdd + NowDec));
        }
    }
}